package com.xin.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class jdbctest_2 {
    public static void main(String[] args) {
        Connection conn=null;
        Statement sta=null;
        try {
            //注册驱动
            Class.forName("com.mysql.jdbc.Driver");
            //数据库连接
            conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/student_manage","root","856736");
            sta=conn.createStatement();
            String sql="update stu_information set stu_id=10,stu_name='zhangsan' where stu_id=1";
            int i = sta.executeUpdate(sql);
            System.out.println(i);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (sta!=null){
                try {
                    sta.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            if (conn!=null){
                try {
                    conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
